package com.example.sunmiv1.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.sunmiv1.R;
import com.example.sunmiv1.entity.ClassificationBean;
import com.example.sunmiv1.entity.ClassifyInfo;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class OneLevelAdapter extends BaseAdapter {
    private Context context;
    private LayoutInflater inflater;
    private List<ClassificationBean.GoodscateBean.ChildBeanX.ChildBean> kindsList;

    public OneLevelAdapter(Context context, List<ClassificationBean.GoodscateBean.ChildBeanX.ChildBean> kindsList) {
        this.inflater = LayoutInflater.from(context);
        this.kindsList = kindsList;
    }

    @Override
    public int getCount() {
        return kindsList.size();
    }

    @Override
    public Object getItem(int i) {
        return kindsList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder vh;
        if (view == null) {
            view = inflater.inflate(R.layout.one_classify_item, null);
            vh = new ViewHolder(view);
            view.setTag(vh);
        } else {
            vh = (ViewHolder) view.getTag();
        }
        vh.childChildTV.setText(kindsList.get(i).getClass_name());
        return view;
    }

    static class ViewHolder {
        @BindView(R.id.childChildTV)
        TextView childChildTV;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
